package zyc.pojo;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: Code-zyc
 * @date: Created in 2020/12/22 10:42
 * @version: v1.0
 * @modified By:
 */
public class Page {
    //每个页面最多索引多少数据
    private  Integer size=5;
    //分页栏连续显示多少
    private  Integer navigatePage=5;
    //默认起始页面
    private  Integer start=0;
    //总共有多少条数据
    private Integer toltal=0;

    //当前第几页
    private Integer pageNum=1;

    //总共有多少页
    private Integer pageNums;

    private List<Integer> navigatepageNums;

    //设计连续显示的页面数据
    public List<Integer> getNavigatepageNums(){
        List<Integer> list=new ArrayList<>();
       if(getPageNum()+getNavigatePage()>getPageNums()){
           if(getPageNums()<=getNavigatePage()){
               for (int i=1;i<=getPageNums();i++){
                   list.add(i);
               }
           }else{
               for (int i=getPageNums()-getNavigatePage()+1;i<=getPageNums();i++){
                   list.add(i);
               }
           }
       }else {
           for (int i=getPageNum();i<getPageNum()+getNavigatePage();i++){
               list.add(i);
           }
       }
        return list;
    }
    //判断有没有上一页
    public boolean getHasPreviousPage(){

        return getPageNum()!=1;
    }
    //判断有没有下一页
    public boolean getHasNextPage(){
        return getPageNum()!=getPageNums();
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageNums() {
        return getToltal()%getSize()==0? getToltal()/getSize():(getToltal()/getSize())+1 ;

    }

    public Integer getToltal() {
        return toltal;
    }

    public void setToltal(Integer toltal) {
        this.toltal = toltal;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getNavigatePage() {
        return navigatePage;
    }

    public void setNavigatePage(Integer navigatePage) {
        this.navigatePage = navigatePage;
    }

    public Integer getStart() {
        return (getPageNum()-1)*getSize();
    }


    @Override
    public String toString() {
        return "Page{" +
                "size=" + size +
                ", navigatePage=" + navigatePage +
                ", start=" + start +
                ", toltal=" + toltal +
                ", pageNum=" + pageNum +
                ", pageNums=" + getPageNums() +
                '}';
    }
}
